home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
ACORNUSERS
/
EMULATOR
/
ASM6502
/
!help
next >
Wrap
Text File
|
1998-08-27
|
9KB
|
179 lines
---------------------------------\---------------------\---\-\ Alain BROBECKER
asm6502 v0.06 (26aug1998) > © Alain BROBECKER > > > rte de Dardagny
---------------------------------/---------------------/---/-/ 01630 CHALLEX
FRANCE
abrobecker@yahoo.com
http://www.cybercable.tm.fr/~brooby/
Contents ---->-->->> 1. Legalities
2. What? Why?
3. asm6502 usage
4. No Future
5. History
-------------------------------> 1. Legalities <------------------------------
* YOU CAN FREELY COPY THIS SOFTWARE AS LONG AS YOU LEAVE FILES UNALTERED,
AND DON'T USE IT FOR COMMERCIAL PROFIT (PDL SHALL CONTACT ME FIRST).
* PLEASE NOTE THAT YOU USE IT (or not =) AT YOUR OWN RISKS! (maybe i shall
mention i do use it at my own risks =)
* COMMENTED SOURCECODE IS PROVIDED FOR INSPIRATION TO ALL CODERS OUT THERE.
USAGE OF PARTS OF CODE OR IDEAS IS ENCOURAGED AS LONG AS YOU CREDIT ME AND
YOUR PRODUCT IS FREEWARE.
------------------------------> 2. What? Why? <-------------------------------
asm6502 is a 6502 cross assembler, ie a program which will convert a source
written for the WDC 6502 processor into the 6502 binary code. What is the use
of such a program on ARM based computers will you ask? There are two possible
answers...
The first is one game programmers encounter a lot: some platforms, like
consoles or computers under development, don't have the software (text editor,
programming languages) and/or hardware (keyboard) to allow easy programming.
The usefulness of cross-programming is then obvious. As an example, Atari's
'Lynx' console is based upon a 6502 (well a 65sc02 in fact) processor. Also,
programming for the Commodore 64 (demos or whatever) would be much easier with
Zap+asm6502 than with a c64 assembler.
The second answer comes from a recent fashion... Emulators. Another of their
possible name would be cross-computers, so cross-programming is dedicated to
your machine again, and cross-programming becomes as useful as programming,
ie a total waste of time. Since I'm delighted at doing such unuseful things,
I programmed asm6502. I hope a side effect of cross-programming will be to
have my knowledge in computers increasing.
Needless to say, I had a c64 when I was young, but used it for gaming only.
One year ago I collected an old c64 (people now throw them away! =) and
decided to program on it. I was impressed by the profimat assembler (macros,
8Kb size, speed), but the c64's basic editor was so lame that I abandonned all
hopes. The only solution was cross-programming. I went through good emulators
and cross-assemblers on the PC, but I did want the same on my Archimedes.
Skoe/Expression already made a cross assembler, but it worked neither on
Arm2+RiscOS2, neither on StrongArm+RiscOS3.7. So it was clear in my mind, I had
to make my own 6502 assembler, and here it is.
Last, i will mention two c64 emulators: Frodo v4.1 by Christian BAUER which
has been adapted to many platforms (Unix, BeOS, Amiga, RiscOS, Win95...), is
freeware, really slow (StrongARM recommended) and has very precise emulation.
The other one, BreadBox64 by Coyer/Daydream Software, is (now) shareware, fast
but less accurate.
--> NEW! <-- My 6502 emulator is now finished, and i have started to work
on an Acorn ATOM emulator: ATOMbomb. Sure you are impatient to see it
launched... =)
-----------------------------> 3. asm6502 usage <-----------------------------
Execute asm6502 from the CLI by typing 'asm6502 SourceName'. The name of
the binary object to produce shall be given in the source with the #name
pseudo-operation.
List of pseudo-operations:
--------------------------
#list ; If you want the assembly listing.
#name filename ; Gives the name to save to.
#type filetype ; Gives the filetype of dest file.
#base imm16 ; Defines the base adress for assembly,
; shall be used once only in a file.
#set variable = value ; Both format are available, but in 1st one
#set variable value ; you must have spaces around the =.
#incbin filename ; Will include the binary file there.
#b imm8, ... ,imm8 ; Byte.
#w imm16, ... ,imm16 ; Word (high byte first).
#rw imm16, ... ,imm16 ; Reversed word (low byte first).
#align mask16,byte ; Copy byte until adress AND mask16=0.
#dsb nb,byte ; Copy byte nb times.
#rept N ; This couple of pseudo-op delimits a zone
#endr ; which will be repeated N times. Very
; usefull, but cannot be nested!
General remarks
---------------
* The 6502 mnemonics are the standard ones, but they must be in lowercase only.
Ooooops, not exactly true, for a zero page access, you must write z,???.
* There are two instruction separators, which are Line Feed (LF=&0a) and ":".
But if you put ":" in a comment it will be ignored, while LF won't.
* The function evaluator uses the BASIC one, so the conventions are similar.
(pfiuuu... This saved me a great lot of coding) So you must use & instead of
the c64's standard $ for hexadecimal values.
As in basic, "aANDb" doesn' t work! Use "a AND b" instead. (Or "a ANDb")
* The "bcc" and "bcs" instructions can be assembled as "blt" (branch less than)
and "bge" (branch greater or equal), respectively.
* Avoid variable names ending with % and $, since I use some of them.
* Both "asl" and "asl a" are valid for accumulator adressing mode, and the
same comment apply for lsr, rol, ror.
* You can't have a variable called "a" since this stands for the accu.
* Some assembler uses "<" or ">" to get low or high byte of an expression.
With asm6502 replace them with "255ANDexpr" or "expr>>8".
* You can give the displacement for the branchs instead of an adress by
writing "b?? -imm8" or "b?? +imm8".
For example: ldy #0
.vsync
cpy &d012
bne -3 ; is equivalent to bne vsync.
* There are two kinds of error reports... When an error has been detected by
asm6502 it looks like "***error at line 1: &100 is not a byte" and the
assembly will continue anyway (total number of errors given at the end).
Second case is when an error has been detected by the BASIC, like in
"Unknown or missing variable at line 1 (asm6502 line 2370)", then assembly
is stopped, the first number indicates where you should look at in your 6502
code while the second one tells where the asm6502 program was when the error
occured (this is usefull for debugging asm6502 =).
-------------------------------> 4. No Future <-------------------------------
Here are some features I would like to add... (Those are no promises! =)
* Macros. (Maybe not that tough)
* Own function evaluator (theory is ready, but code isn't), because BASIC's
one (is convenient but) doesn't suit this usage: it won't detect some errors
such as label redefinition.
* Local labels. (Needs own function evaluator?)
* #ascii pseudo-op. (or #b "...."?)
* #include pseudo-op. (Replace main loop by a procedure?)
* Uppercase possibility. (By converting everything to lowercase beforehand?
Having opcodes in lower+upper cases?)
* Hash code table instead of dichotomy.
* Rewriting in assembly (efficiency) or C (portability).
--------------------------------> 5. History <--------------------------------
26aug1998 v0.06 -- Removed bug in #rept.
-- Now a ":" in a comment is ignored.
-- Changed display of BASIC's error report.
-- Now displays #dsb,#align as memory dump (as for #incbin).
-- Changed c64 examples to have them filetyped to &064.
-- Old emul6502 programs replaced by more interesting ones.
03aug1998 v0.05 -- Corrected memory dump display of "#incbin" listing.
31may1998 v0.04 -- Since I have begun the 6502 emulator, I have used asm6502
a lot to produce small test progs. Bugs seem to despise
this program, so here it is at l(e)ast... =)
01mar1998 v0.04ß -- Cleaned the code, added #type pseudo-op and allowed space
as a separator just after a label.
09sep1997 v0.03ß -- Added "b?? +imm8" & "b?? -imm8" assembly, improved the
FNsize function and modified operand identification.
08sep1997 v0.02ß -- Added dichotomy for mnemonic identification and changed
string accesses, resulting in 25% speed increase.
07sep1997 v0.01ß -- First (seemingly) working version. Let's face it, I'm
happy, but I will have to perform intensive testing
before I unleash the beast.
18may1997 v0.00ß -- 'asm6502' project started (and soon halted =).